<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ArkUtils</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ArkUtils</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/ark_utils_rb.html">
                lib/ark_utils.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000016">mint</a>&nbsp;&nbsp;
      <a href="#M000017">validate</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">XDIGITS</td>
          <td>=</td>
          <td class="context-item-value">%w( 0 1 2 3 4 5 6 7 8 9 b c d f g h j k m n p q r s t v w x z )</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">DIGITS</td>
          <td>=</td>
          <td class="context-item-value">XDIGITS[0..9]</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <a href="#M000016" class="method-signature">
          <span class="method-name">mint</span><span class="method-args">( options={ :authority =&gt; nil, :template =&gt; 'dddddddd' } )</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000016-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ark_utils.rb, line 6</span>
 6:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mint</span>( <span class="ruby-identifier">options</span>={ <span class="ruby-identifier">:authority</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:template</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'dddddddd'</span> } )
 7:       <span class="ruby-comment cmt"># mint a unique ARK within the given authority</span>
 8:       <span class="ruby-comment cmt"># random template: eeddeeddk</span>
 9:       <span class="ruby-comment cmt">#   e is an xdigit: 0123456789bcdfghjkmnpqrstvwxz</span>
10:       <span class="ruby-comment cmt">#   d is a digit:   0123456789</span>
11:       <span class="ruby-comment cmt">#   k is checkchar: special xdigit</span>
12:  
13:       <span class="ruby-comment cmt"># first generate a name based on given template</span>
14:       <span class="ruby-identifier">name</span> = <span class="ruby-identifier">generate_name</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:template</span>] )
15: 
16:       <span class="ruby-comment cmt"># then prepend authority.number and the '/' character e.g., &quot;11111/id&quot;</span>
17:       <span class="ruby-identifier">ark</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:authority</span>].<span class="ruby-identifier">number</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">name</span> 
18: 
19:       <span class="ruby-comment cmt"># then generate a check character, if specified in template</span>
20:       <span class="ruby-identifier">name</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">generate_check</span>( <span class="ruby-identifier">ark</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:template</span>][<span class="ruby-value">-1</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'k'</span>
21: 
22:       <span class="ruby-comment cmt"># return identifier w/ check char to caller</span>
23:       <span class="ruby-identifier">name</span>
24:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000017" class="method-detail">
        <a name="M000017"></a>

        <div class="method-heading">
          <a href="#M000017" class="method-signature">
          <span class="method-name">validate</span><span class="method-args">( ark )</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000017-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ark_utils.rb, line 46</span>
46:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate</span>( <span class="ruby-identifier">ark</span> )
47:       <span class="ruby-identifier">generate_check</span>( <span class="ruby-identifier">ark</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>] ) <span class="ruby-operator">==</span> <span class="ruby-identifier">ark</span>[<span class="ruby-value">-1</span>].<span class="ruby-identifier">chr</span> 
48:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>